<template>
    <div class="home-view">
        <section class="banner-sidebar-section">
            <div class="container">
                <div class="banner-sidebar-wrapper">
                    <div class="sidebar-left">
                        <el-card class="sidebar-card hot-articles-card" shadow="hover">
                            <template #header>
                                <div class="card-header">
                                    <el-icon class="header-icon">
                                        <Star />
                                    </el-icon>
                                    <span>热门文章</span>
                                </div>
                            </template>
                            <div class="hot-articles-list">
                                <div v-for="(item, index) in hotArticles" :key="item.id" class="hot-article-item"
                                    @click="goToDetail(item.id)">
                                    <div class="hot-article-rank" :class="`rank-${index + 1}`">
                                        {{ index + 1 }}
                                    </div>
                                    <div class="hot-article-content">
                                        <div class="hot-article-title">{{ item.title }}</div>
                                        <div class="hot-article-meta">
                                            <span class="hot-article-views">
                                                <el-icon>
                                                    <View />
                                                </el-icon>
                                                {{ item.view_count || 0 }}
                                            </span>
                                        </div>
                                    </div>
                                </div>
                                <div v-if="hotArticles.length === 0" class="empty-state">
                                    暂无热门文章
                                </div>
                            </div>
                        </el-card>
                    </div>

                    <div class="banner-right">
                        <div class="banner-wrapper">
                            <swiper v-if="slides.length != 0" :modules="modules"
                                :autoplay="{ delay: 4000, disableOnInteraction: false }" :slides-per-view="1"
                                :pagination="{ clickable: true }" :loop="true" :effect="'fade'" class="banner-swiper">
                                <swiper-slide v-for="(item) in slides" :key="item.id">
                                    <div class="banner-slide" @click="handleBannerClick(item)">
                                        <el-image :src="item.banner_url" :alt="item.banner_title" fit="cover"
                                            class="banner-image">
                                            <template #error>
                                                <div class="image-slot">
                                                    <el-icon>
                                                        <Picture />
                                                    </el-icon>
                                                    <span>图片加载失败</span>
                                                </div>
                                            </template>
                                        </el-image>
                                        <div class="banner-overlay">
                                            <h2 class="banner-title">{{ item.banner_title }}</h2>
                                        </div>
                                    </div>
                                </swiper-slide>
                            </swiper>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <section class="articles-section">
            <div class="container">
                <div class="section-header">
                    <h2 class="section-title">
                        <el-icon>
                            <Document />
                        </el-icon>
                        <span>最新文章</span>
                    </h2>
                    <p class="section-subtitle">发现更多精彩内容</p>
                </div>

                <div class="articles-grid">
                    <el-card v-for="(item, index) in articles" :key="item.id" class="article-card" shadow="hover"
                        :ref="(el: any) => { if (el) articleCardRefs[index] = el }">
                        <div class="card-image" @click="goToDetail(item.id)">
                            <el-image :src="item.src" :alt="item.title" fit="cover" lazy>
                                <template #error>
                                    <div class="image-slot">
                                        <el-icon>
                                            <Picture />
                                        </el-icon>
                                    </div>
                                </template>
                            </el-image>
                            <div class="card-category">
                                <el-tag v-bind="getTagProps(item.cate)" size="small">
                                    {{ item.cate }}
                                </el-tag>
                            </div>
                        </div>

                        <div class="card-content">
                            <h3 class="card-title" @click="goToDetail(item.id)">
                                {{ item.title }}
                            </h3>

                            <div class="card-excerpt" v-html="item.content"></div>

                            <div class="card-footer">
                                <div class="card-meta">
                                    <span class="meta-item">
                                        <el-icon>
                                            <User />
                                        </el-icon>
                                        {{ item.author }}
                                    </span>
                                    <span class="meta-item">
                                        <el-icon>
                                            <Calendar />
                                        </el-icon>
                                        {{ formatDate(item.createAt) }}
                                    </span>
                                    <span class="meta-item">
                                        <el-icon>
                                            <View />
                                        </el-icon>
                                        {{ item.view_count || 0 }}
                                    </span>
                                </div>
                                <el-button type="primary" size="small" @click="goToDetail(item.id)" text>
                                    阅读更多
                                    <el-icon class="el-icon--right">
                                        <ArrowRight />
                                    </el-icon>
                                </el-button>
                            </div>
                        </div>
                    </el-card>
                </div>

                <div class="load-more" v-if="articles.length > 0">
                    <el-button v-if="hasMore && !isLoading" type="primary" size="large" round @click="loadMore">
                        加载更多
                        <el-icon class="el-icon--right">
                            <ArrowDown />
                        </el-icon>
                    </el-button>
                    <el-button v-else-if="isLoading" type="primary" size="large" round :loading="true">
                        加载中...
                    </el-button>
                    <el-button v-else type="info" size="large" round disabled>
                        没有更多文章啦
                    </el-button>
                </div>
            </div>
        </section>
    </div>
</template>

<script setup lang="ts">
import { bannerList, articleItems, host, getHotArticles } from '@/api/index'
import { Swiper, SwiperSlide } from 'swiper/vue'
import { Pagination, Scrollbar, A11y, EffectFade, Autoplay } from 'swiper/modules'
import { useRouter } from 'vue-router'
import { ref, onMounted, nextTick, computed } from 'vue'
import { gsap } from 'gsap'
import {
    Document,
    Picture,
    User,
    Calendar,
    ArrowRight,
    ArrowDown,
    Star,
    View
} from '@element-plus/icons-vue'
import 'swiper/swiper-bundle.css'
import 'swiper/css/pagination'
import 'swiper/css/scrollbar'
import 'swiper/css/effect-fade'

const router = useRouter()
const modules = [Pagination, Scrollbar, A11y, EffectFade, Autoplay]

interface IBanner {
    id: number
    banner_link: string
    banner_title: string
    banner_url: string
    [key: string | number]: string | number
}

interface IItem {
    id: number
    title: string
    author: string
    cate: string
    cate_name: string
    content: string
    createAt: string
    src: string
    tag: string
    view_count?: number
    status?: string
    [key: string | number]: string | any
}

const slides = ref<IBanner[]>([])
const pageSize = ref<number>(6)
const allPublishedArticles = ref<IItem[]>([]) // 存储已获取的已发布文章
const displayedCount = ref<number>(6) // 当前已显示的文章数量
const articles = ref<IItem[]>([]) // 当前显示的文章
const hotArticles = ref<IItem[]>([])
const articleCardRefs = ref<any[]>([])
const hasMore = ref<boolean>(true)
const isLoading = ref<boolean>(false)
const lastLoadedPage = ref<number>(0) // 记录最后加载的页码

const bannerListFn = async () => {
    await bannerList().then((resData: any) => {
        if (resData.code == 200) {
            let { result } = resData
            let arr = result.map((item: IBanner) => {
                if (item.banner_url && typeof item.banner_url === 'string') {
                    if (item.banner_url.startsWith('http://') || item.banner_url.startsWith('https://')) {
                        item.banner_url = item.banner_url
                    } else {
                        const urlPath = item.banner_url.startsWith('/') ? item.banner_url : '/' + item.banner_url
                        item.banner_url = host + urlPath
                    }
                }
                return item
            })
            slides.value = arr
        }
    }).catch((err) => {
        console.error('获取轮播图数据失败:', err)
    })
}

// 筛选已发布的文章
const filterPublishedArticles = (data: IItem[]): IItem[] => {
    return data.filter((item: IItem) => item.status === 'published')
}

// 获取并处理文章数据
const processArticleData = (data: IItem[]): IItem[] => {
    return data.map((item: IItem) => {
        const date = new Date(item.createAt)
        item.createAt = date.toISOString()
        item.src = host + item.src
        return item
    })
}

// 按发布时间排序（最新的在前）
const sortArticlesByDate = (articles: IItem[]): IItem[] => {
    return [...articles].sort((a, b) => {
        const dateA = new Date(a.createAt).getTime()
        const dateB = new Date(b.createAt).getTime()
        return dateB - dateA // 降序，最新的在前
    })
}

// 更新显示的文章列表
const updateDisplayedArticles = () => {
    articles.value = allPublishedArticles.value.slice(0, displayedCount.value)
    // 如果已显示的数量小于已获取的数量，说明还有未显示的文章
    hasMore.value = displayedCount.value < allPublishedArticles.value.length
}

// 加载文章数据（按时间顺序）
const loadArticlesData = async (page: number, batchSize: number = 50): Promise<{ articles: IItem[], hasMore: boolean }> => {
    try {
        const resData = await articleItems({ page_size: batchSize, page_num: page })
        if (resData.code == 200) {
            let { data } = resData
            if (data.length === 0) {
                return { articles: [], hasMore: false }
            }

            let processedData = processArticleData(data)
            let publishedArticles = filterPublishedArticles(processedData)

            // 如果返回的数据少于batchSize，说明可能没有更多了
            const hasMoreData = data.length >= batchSize

            return { articles: publishedArticles, hasMore: hasMoreData }
        }
        return { articles: [], hasMore: false }
    } catch (err) {
        console.error('获取文章失败:', err)
        return { articles: [], hasMore: false }
    }
}

// 初始加载：获取最新的已发布文章
const articleItemsFn = async () => {
    if (isLoading.value) return
    isLoading.value = true

    try {
        allPublishedArticles.value = []
        displayedCount.value = pageSize.value
        lastLoadedPage.value = 0

        // 获取第一批文章（按时间倒序，最新的在前）
        let page = 1
        let collectedArticles: IItem[] = []
        const batchSize = 50
        let hasMoreData = true

        // 获取足够多的文章以支持初始显示和后续加载
        while (page <= 5 && hasMoreData) { // 先获取5页，确保有足够的数据
            const result = await loadArticlesData(page, batchSize)
            if (result.articles.length > 0) {
                collectedArticles = [...collectedArticles, ...result.articles]
                lastLoadedPage.value = page
                hasMoreData = result.hasMore
                if (!result.hasMore) {
                    break
                }
            } else {
                hasMoreData = false
                break
            }
            page++
        }

        // 按发布时间排序（最新的在前）
        allPublishedArticles.value = sortArticlesByDate(collectedArticles)

        // 初始显示6篇
        updateDisplayedArticles()

        // 检查是否还有更多数据
        // 如果已获取的文章数量大于显示数量，说明还有未显示的文章（updateDisplayedArticles 已处理）
        // 如果已获取的文章数量等于显示数量，但在加载过程中还有更多数据，也可能有更多
        // 这种情况会在 loadMore 时尝试加载更多数据
        // 如果已获取的文章数量少于显示数量，且没有更多数据，则没有更多了
        if (allPublishedArticles.value.length < displayedCount.value && !hasMoreData) {
            hasMore.value = false
        }

        nextTick(() => {
            animateArticles()
        })
    } catch (error) {
        console.error('获取文章列表失败:', error)
        hasMore.value = false
    } finally {
        isLoading.value = false
    }
}

const getHotArticlesFn = async () => {
    await getHotArticles(5).then((resData: any) => {
        if (resData.code == 200) {
            // 筛选只显示已发布的文章
            let allArticles = resData.data || []
            hotArticles.value = filterPublishedArticles(allArticles)
        }
    })
}

const goToDetail = (id: number) => {
    router.push({ path: '/detail', query: { id } })
}

const handleBannerClick = (item: IBanner) => {
    if (item.banner_link) {
        window.open(item.banner_link, '_blank')
    }
}

const formatDate = (dateStr: string) => {
    const date = new Date(dateStr)
    return date.toLocaleDateString('zh-CN', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit'
    })
}

const getCategoryType = (cate: string): 'success' | 'warning' | 'danger' | undefined => {
    const typeMap: Record<string, 'success' | 'warning' | 'danger'> = {
        '工作生活': 'success',
        '技能学习': 'warning',
        '兴趣爱好': 'danger'
    }
    return typeMap[cate] || undefined
}

const getTagProps = (cate: string) => {
    const type = getCategoryType(cate)
    return type ? { type } : {}
}

const loadMore = async () => {
    if (isLoading.value || !hasMore.value) return

    // 如果已获取的文章还有未显示的，直接显示更多
    if (displayedCount.value < allPublishedArticles.value.length) {
        displayedCount.value += pageSize.value
        updateDisplayedArticles()
        nextTick(() => {
            animateArticles()
        })
        return
    }

    // 如果已获取的文章都已显示，尝试加载更多
    isLoading.value = true
    try {
        const nextPage = lastLoadedPage.value + 1
        const batchSize = 50
        const result = await loadArticlesData(nextPage, batchSize)

        if (result.articles.length > 0) {
            // 合并新获取的文章，并重新排序
            const mergedArticles = [...allPublishedArticles.value, ...result.articles]
            allPublishedArticles.value = sortArticlesByDate(mergedArticles)
            lastLoadedPage.value = nextPage

            // 显示更多文章
            displayedCount.value += pageSize.value
            updateDisplayedArticles()

            // 如果新加载的数据少于batchSize，说明可能没有更多了
            // 并且如果已显示的已经等于已获取的全部，则没有更多了
            if (!result.hasMore && displayedCount.value >= allPublishedArticles.value.length) {
                hasMore.value = false
            } else {
                hasMore.value = true
            }

            nextTick(() => {
                animateArticles()
            })
        } else {
            // 没有更多文章了
            hasMore.value = false
        }
    } catch (error) {
        console.error('加载更多文章失败:', error)
        hasMore.value = false
    } finally {
        isLoading.value = false
    }
}

const animateArticles = () => {
    const cards = articleCardRefs.value
    cards.forEach((card, index) => {
        if (card && card.$el) {
            gsap.fromTo(
                card.$el,
                {
                    opacity: 0,
                    y: 50
                },
                {
                    opacity: 1,
                    y: 0,
                    duration: 0.6,
                    delay: index * 0.1,
                    ease: 'power3.out'
                }
            )
        }
    })
}

onMounted(() => {
    nextTick(() => {
        const sidebarCards = document.querySelectorAll('.sidebar-card')
        sidebarCards.forEach((card, index) => {
            gsap.fromTo(
                card,
                {
                    opacity: 0,
                    x: -50
                },
                {
                    opacity: 1,
                    x: 0,
                    duration: 0.8,
                    delay: index * 0.2,
                    ease: 'power3.out'
                }
            )
        })

        const bannerWrapper = document.querySelector('.banner-wrapper')
        if (bannerWrapper) {
            gsap.fromTo(
                bannerWrapper,
                {
                    opacity: 0,
                    x: 50,
                    scale: 0.95
                },
                {
                    opacity: 1,
                    x: 0,
                    scale: 1,
                    duration: 1,
                    delay: 0.3,
                    ease: 'power3.out'
                }
            )
        }

    })

    const articlesSection = document.querySelector('.articles-section')
    if (articlesSection) {
        const observer = new IntersectionObserver(
            (entries) => {
                entries.forEach((entry) => {
                    if (entry.isIntersecting) {
                        animateArticles()
                        observer.unobserve(entry.target)
                    }
                })
            },
            { threshold: 0.1 }
        )
        observer.observe(articlesSection)
    }
})

bannerListFn()
articleItemsFn()
getHotArticlesFn()
</script>

<style lang="less" scoped>
@import "../assets/varable.less";

.home-view {
    background: @bg-primary;
}

.banner-sidebar-section {
    margin-bottom: 50px;

    .banner-sidebar-wrapper {
        display: grid;
        grid-template-columns: 380px 1fr;
        gap: 30px;
        align-items: stretch;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .sidebar-left {
        display: flex;
        flex-direction: column;
        gap: 20px;
        height: 100%;
    }

    .sidebar-card {
        border-radius: 12px;
        overflow: hidden;
        transition: all 0.3s;

        &:hover {
            transform: translateY(-5px);
            box-shadow: @shadow-lg;
        }

        .card-header {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 16px;
            font-weight: 600;
            color: @text-primary;

            .header-icon {
                font-size: 20px;
                color: @primary-color;
            }
        }
    }

    .hot-articles-card {
        height: 100%;
        display: flex;
        flex-direction: column;

        :deep(.el-card__body) {
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .hot-articles-list {
            flex: 1;

            .hot-article-item {
                display: flex;
                align-items: center;
                gap: 12px;
                padding: 12px 0;
                cursor: pointer;
                transition: all 0.3s;
                border-bottom: 1px solid @border-light;

                &:last-child {
                    border-bottom: none;
                }

                &:hover {
                    padding-left: 8px;

                    .hot-article-title {
                        color: @primary-color;
                    }
                }

                .hot-article-rank {
                    width: 28px;
                    height: 28px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    border-radius: 6px;
                    font-weight: bold;
                    font-size: 14px;
                    flex-shrink: 0;
                    background: @primary-lighter;
                    color: @primary-color;

                    &.rank-1 {
                        background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
                        color: #fff;
                    }

                    &.rank-2 {
                        background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
                        color: #fff;
                    }

                    &.rank-3 {
                        background: linear-gradient(135deg, #cd7f32 0%, #e6a85c 100%);
                        color: #fff;
                    }
                }

                .hot-article-content {
                    flex: 1;
                    min-width: 0;

                    .hot-article-title {
                        font-size: 14px;
                        color: @text-primary;
                        margin-bottom: 6px;
                        line-height: 1.5;
                        display: -webkit-box;
                        -webkit-box-orient: vertical;
                        -webkit-line-clamp: 2;
                        line-clamp: 2;
                        overflow: hidden;
                        transition: color 0.3s;
                    }

                    .hot-article-meta {
                        display: flex;
                        align-items: center;
                        gap: 8px;
                        font-size: 12px;
                        color: @text-light;

                        .hot-article-views {
                            display: flex;
                            align-items: center;
                            gap: 4px;

                            .el-icon {
                                font-size: 14px;
                            }
                        }
                    }
                }
            }

            .empty-state {
                text-align: center;
                padding: 20px;
                color: @text-light;
                font-size: 14px;
            }
        }
    }

    .banner-right {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: 100%;

        .banner-wrapper {
            width: 100%;
            max-width: 100%;
            height: 100%;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: @shadow-lg;
        }

        .banner-swiper {
            width: 100%;
            max-width: 100%;
            height: 100%;
            border-radius: 16px;

            :deep(.swiper-wrapper) {
                width: 100%;
                max-width: 100%;
            }

            :deep(.swiper-slide) {
                width: 100%;
                max-width: 100%;
            }

            :deep(.swiper-pagination) {
                bottom: 25px;
            }

            :deep(.swiper-pagination-bullet) {
                width: 12px;
                height: 12px;
                background: @text-white;
                opacity: 0.5;
                transition: all 0.3s;
            }

            :deep(.swiper-pagination-bullet-active) {
                width: 32px;
                border-radius: 6px;
                background: @text-white;
                opacity: 1;
            }
        }

        .banner-slide {
            position: relative;
            width: 100%;
            height: 100%;
            cursor: pointer;
            overflow: hidden;

            .banner-image {
                width: 100%;
                height: 100%;
                max-width: 100%;
                display: block;

                :deep(.el-image__inner) {
                    width: 100%;
                    height: 100%;
                    max-width: 100%;
                    object-fit: cover;
                    display: block;
                }
            }

            .image-slot {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                width: 100%;
                height: 100%;
                background: @primary-lighter;
                color: @primary-light;
                font-size: 14px;

                .el-icon {
                    font-size: 48px;
                    margin-bottom: 10px;
                }
            }

            .banner-overlay {
                position: absolute;
                bottom: 0;
                left: 0;
                right: 0;
                background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
                padding: 40px;
                color: @text-white;
                z-index: 1;

                .banner-title {
                    font-size: 28px;
                    font-weight: bold;
                    margin: 0;
                    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
                }
            }
        }
    }
}

.articles-section {
    .section-header {
        text-align: center;
        margin-bottom: 50px;

        .section-title {
            display: inline-flex;
            align-items: center;
            gap: 12px;
            font-size: 32px;
            font-weight: bold;
            color: @text-primary;
            margin-bottom: 15px;

            .el-icon {
                font-size: 36px;
                color: @primary-color;
            }
        }

        .section-subtitle {
            color: @text-secondary;
            font-size: 16px;
            margin: 0;
        }
    }

    .articles-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 30px;
        margin-bottom: 50px;
    }

    .article-card {
        border-radius: 12px;
        overflow: hidden;
        transition: all 0.3s;
        cursor: pointer;
        border: none;

        &:hover {
            transform: translateY(-8px);
            box-shadow: @shadow-lg;

            .card-image {
                img {
                    transform: scale(1.1);
                }
            }

            .card-title {
                color: @primary-color;
            }
        }

        :deep(.el-card__body) {
            padding: 0;
        }
    }

    .card-image {
        position: relative;
        height: 220px;
        overflow: hidden;
        background: @bg-primary;

        .el-image {
            width: 100%;
            height: 100%;
            transition: transform 0.3s;
        }

        img {
            transition: transform 0.5s ease;
        }

        .image-slot {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
            background: @primary-lighter;
            color: @primary-light;

            .el-icon {
                font-size: 48px;
            }
        }

        .card-category {
            position: absolute;
            top: 15px;
            right: 15px;
        }
    }

    .card-content {
        padding: 20px;
    }

    .card-title {
        font-size: 18px;
        font-weight: 600;
        color: @text-primary;
        margin-bottom: 12px;
        line-height: 1.6;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
        transition: color 0.3s;
        cursor: pointer;
    }

    .card-excerpt {
        color: @text-secondary;
        font-size: 14px;
        line-height: 1.8;
        margin-bottom: 15px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        overflow: hidden;

        :deep(p) {
            margin: 0;
        }

        :deep(*) {
            font-size: 14px !important;
            line-height: 1.8 !important;
        }
    }

    .card-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 15px;
        border-top: 1px solid @border-light;
    }

    .card-meta {
        display: flex;
        gap: 15px;
        flex-wrap: wrap;

        .meta-item {
            display: flex;
            align-items: center;
            gap: 5px;
            color: @text-light;
            font-size: 13px;

            .el-icon {
                font-size: 14px;
            }
        }
    }

    .load-more {
        text-align: center;
        margin-top: 30px;
    }
}

@media (max-width: 1200px) {
    .banner-sidebar-section {
        .banner-sidebar-wrapper {
            grid-template-columns: 320px 1fr;
            gap: 20px;
        }
    }

    .articles-section {
        .articles-grid {
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 25px;
        }
    }
}

@media (max-width: 992px) {
    .banner-sidebar-section {
        .banner-sidebar-wrapper {
            grid-template-columns: 1fr;
            gap: 20px;
            align-items: start;
        }

        .sidebar-left {
            height: auto;
        }

        .hot-articles-card {
            height: auto;
        }

        .banner-right {
            height: auto;

            .banner-wrapper {
                height: auto;
            }

            .banner-swiper {
                height: 400px;
            }

            .banner-slide {
                .banner-overlay {
                    padding: 30px;

                    .banner-title {
                        font-size: 24px;
                    }
                }
            }
        }
    }

    .articles-section {
        .section-header {
            margin-bottom: 40px;

            .section-title {
                font-size: 28px;

                .el-icon {
                    font-size: 32px;
                }
            }
        }

        .articles-grid {
            grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
            gap: 20px;
        }
    }
}

@media (max-width: 768px) {
    .banner-sidebar-section {
        margin-bottom: 30px;

        .banner-right {
            .banner-swiper {
                height: 300px;
                border-radius: 12px;
            }

            .banner-slide {
                .banner-overlay {
                    padding: 20px;

                    .banner-title {
                        font-size: 20px;
                    }
                }
            }
        }
    }

    .articles-section {
        .section-header {
            margin-bottom: 30px;

            .section-title {
                font-size: 24px;

                .el-icon {
                    font-size: 28px;
                }
            }

            .section-subtitle {
                font-size: 14px;
            }
        }

        .articles-grid {
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 20px;
        }

        .card-image {
            height: 180px;
        }
    }
}

@media (max-width: 576px) {
    .banner-sidebar-section {
        .banner-right {
            .banner-swiper {
                height: 250px;
                border-radius: 0;
            }

            .banner-slide {
                .banner-overlay {
                    padding: 15px;

                    .banner-title {
                        font-size: 18px;
                    }
                }
            }
        }
    }

    .articles-section {
        .articles-grid {
            grid-template-columns: 1fr;
            gap: 15px;
        }

        .article-card {
            &:hover {
                transform: translateY(-4px);
            }
        }

        .card-footer {
            flex-direction: column;
            align-items: flex-start;
            gap: 12px;
        }
    }
}
</style>
